package com.xsx.servlet;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class Servlet1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");
        System.out.println("在serv1 (柜台1)中查看的参数（材料）：" + username);

        //给材料盖一个章 并传递到serv2（柜台2）去查看
        req.setAttribute("key1", "柜台1的章");
        //问路：servlet2(柜台2)怎么走
        //请求转发必须要以斜杠打头，/斜杠表示地址为:http://ip:portl工程名/，映射到TDEA代码的web目录<br/>
//        RequestDispatcher requestDispatcher = req.getRequestDispatcher("/servlet2");
        //这样可以访问到 WEB-INF下的文件
        RequestDispatcher requestDispatcher = req.getRequestDispatcher("/WEB-INF/a.html");

        //走向Servlet2
        requestDispatcher.forward(req, resp);


    }
}
